// 将权限属于父节点的id全过滤掉
export function filterPermissions(preIdsList: number[], menuList: any[]) {
  const newIdsList: number[] = []
  preIdsList.forEach((id) => {
    findId(id, menuList)
  })

  function findId(id: number, menuList: any[]) {
    for (const menu of menuList) {
      if (menu.menuId === id && menu.children.length === 0) {
        newIdsList.push(id)
        break
      } else {
        findId(id, menu.children)
      }
    }
  }

  return newIdsList
}

export default filterPermissions
